﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using zhangmenren.IService;
using zhangmenren.Models;
using zhangmenren.Repository;
using zhangmenren.ViewModel;

namespace zhangmenren.Service
{
    public class RealService : IRealService
    {
        private RealRepository realRepository = new RealRepository();

        public Task<RealEntity> FindById(int id)
        {
            return Task.FromResult(realRepository.FindById(id).FirstOrDefault());
        }

        public Task<RealEntity> FindByUser(int userid)
        {
            return Task.FromResult(realRepository.FindByUserId(userid).FirstOrDefault());
        }

        public Task<IEnumerable<RealMode>> Selelct()
        {
            return Task.FromResult(realRepository.Select());
        }

        public Task<int> Add(RealEntity entity)
        {
            return Task.FromResult(realRepository.Add(entity));
        }

        public Task<int> UpState(int id ,int state)
        {
            return Task.FromResult(realRepository.UpState(id,state));
        }

        public Task<int> Del(int id)
        {
            return Task.FromResult(realRepository.Del(id));
        }
    }
}
